class Solution {
    public int jump(int[] nums) {
        int end=0;
        int maxlen=0;
        int step=0;
        for(int i=0;i<nums.length-1;i++)
        {
            maxlen=Math.max(maxlen,i+nums[i]);
            if(i==end)
            {
                step++;
                end=maxlen;
            }
        }
        return step;
    }
} 
